package com.javasm.service.impl;

import com.javasm.dao.SkillGameServerDao;
import com.javasm.entity.SkillGameServer;
import com.javasm.service.SkillGameServerService;
import com.javasm.utils.MyBatisHeapler;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


/**
 * 技能区服(CustomerSkillGameServer)表服务实现类
 *
 * @author makejava
 * @since 2024-08-21 16:28:23
 */

public class SkillGameServerServiceImpl implements SkillGameServerService {

    @Override
    public List<SkillGameServer> listAllGameServer(SkillGameServer inputGameServer, Integer page, Integer pageSize) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameServerDao gameDao = sqlSession.getMapper(SkillGameServerDao.class);
        List<SkillGameServer> listGame = gameDao.listAllGameServer(inputGameServer,(page-1)*pageSize,pageSize);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return listGame;
    }

    @Override
    public Integer countGameServers(SkillGameServer inputGameServer) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameServerDao gameDao = sqlSession.getMapper(SkillGameServerDao.class);
        Integer total = gameDao.countGameServers(inputGameServer);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return total;
    }
    @Override
    public Integer addGameServer(SkillGameServer inputGameServer) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameServerDao gameDao = sqlSession.getMapper(SkillGameServerDao.class);
        Integer result = gameDao.addGameServer(inputGameServer);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return result;
    }
    @Override
    public Integer deleteGameServerById(Integer gameServerId) {
        SqlSession sqlSession = MyBatisHeapler.getSqlSession();

        SkillGameServerDao gameDao = sqlSession.getMapper(SkillGameServerDao.class);
        Integer result = gameDao.deleteGameServerById(gameServerId);

        MyBatisHeapler.backAndSaveSqlSession(sqlSession);
        return result;
    }



}
